Fix fetch() on git < 1.7.3
authorAlex Crichton <alex@alexcrichton.com>
Tue, 1 Jul 2014 02:37:55 +0000 (19:37 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 1 Jul 2014 03:19:30 +0000 (20:19 -0700)
Apparently these versions of git are broken for `git fetch $url`, so we have to
resort to `git fetch origin` and then just pray that it hasn't changed in the
meantime.

src/cargo/sources/git/utils.rs

index b92fdcb0fd093b27e705fe79a86866412ec0d876..73d1c91372bb1c3edfdc0157bce3f16ef5d33d26 100644 (file)
@@ -265,12 +265,18 @@ impl GitCheckout {
         // --tags on 1.9. For simplicity, we execute with and without --tags for
         // all gits.
         //
-        // FIXME: This is suspicious. I have been informated that, for example,
+        // FIXME: This is suspicious. I have been informed that, for example,
         //        bundler does not do this, yet bundler appears to work!
-        git!(self.location, "fetch --force --quiet {}",
-             self.get_source().display());
-        git!(self.location, "fetch --force --quiet --tags {}",
-             self.get_source().display());
+        //
+        // And to continue the fun, git before 1.7.3 had the fun bug that if a
+        // branch was tracking a remote, then `git fetch $url` doesn't work!
+        //
+        // For details, see
+        // https://www.kernel.org/pub/software/scm/git/docs/RelNotes-1.7.3.txt
+        //
+        // In this case we just use `origin` here instead of the database path.
+        git!(self.location, "fetch --force --quiet origin");
+        git!(self.location, "fetch --force --quiet --tags origin");
         try!(self.reset(self.revision.as_slice()));
         Ok(())
     }